#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 105;

int n, m;
int t[N];
int f[N], b[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> t[i];
  rep(i, 1, n) {
    f[i] = 1;
    rep(j, 1, i - 1) if (t[j] < t[i]) f[i] = max(f[i], 1 + f[j]);
  }
  per(i, n, 1) {
    b[i] = 1;
    per(j, n, i + 1) if (t[j] < t[i]) b[i] = max(b[i], 1 + b[j]);
  }
  int ans = 0;
  rep(i, 1, n) ans = max(ans, f[i] + b[i] - 1);
  cout << n - ans;
  return 0;
}